package com.blkj.modular.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blkj.common.core.entity.UserEntity;
import com.blkj.modular.user.mapper.UserMapper;
import com.blkj.modular.user.service.UserService;
import org.springframework.stereotype.Service;

/**
 * @author 北浪 2021/11/19
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {

    @Override
    public UserEntity userLogin(String username, String password) {
        QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",username);
        queryWrapper.eq("password",password);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public UserEntity getUserByUsername(String username) {
        QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",username);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public UserEntity getUserById(Integer id) {
        return baseMapper.selectById(id);
    }
}
